package com.twu.biblioteca;

public class BibliotecaApp implements Runnable {

    private UserInterface userInterface;

    private ControllerManager controllerManager;

    private BookRepository bookRepository;

    private UserRepository userRepository;

    private MovieRepository movieRepository;

    private InputDispatcher inputDispatcher;

    BibliotecaApp(UserInterface userInterface, InputDispatcher inputDispatcher, BookRepository bookRepository, MovieRepository movieRepository, ControllerManager controllerManager, UserRepository userRepository) {
        this.userInterface = userInterface;
        this.bookRepository = bookRepository;
        this.controllerManager = controllerManager;
        this.movieRepository = movieRepository;
        this.inputDispatcher = inputDispatcher;
        this.userRepository = userRepository;
    }

    public static void main(String[] args) {
        BibliotecaAppBuilder builder = new BibliotecaAppBuilder();
        BibliotecaApp app = builder.bibliotecaApp();
        app.run();
    }

    UserInterface getUserInterface() {
        return userInterface;
    }

    BookRepository getBookRepository() {
        return bookRepository;
    }

    UserRepository getUserRepository() {
        return userRepository;
    }

    MovieRepository getMovieRepository() {
        return movieRepository;
    }

    @Override
    public void run() {
        userInterface.showWelcome();
        controllerManager.init();
        inputDispatcher.run();
    }

}
